package it.struts.helloworld.services;

import it.struts.helloworld.model.Utenti;
import it.struts.helloworld.utils.HibernateUtils;

import org.hibernate.Query;
import org.hibernate.Session;

public class LoginService {
	
	Session sess;
    
    public Utenti retrieveDetails(String username){
        try{
            sess = HibernateUtils.getSessionFactory();
            Query query = sess.createQuery("FROM Utenti WHERE username = :usern");
            query.setParameter("usern", username);
            return (Utenti) query.uniqueResult();
        }
        catch(Exception exep){
            exep.printStackTrace();
        }
        
        return null;
    }
}